import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    unickname: sessionStorage.getItem('unickname'), //全局共享 当前登录用户的名字
    // uid: null, //当前登录用户的uid
    uid: sessionStorage.getItem('uid'),
    uemail: sessionStorage.getItem('uemail'),
    ulogo: sessionStorage.getItem('ulogo'),
  },
  getters: {},
  mutations: {
    updateUnickname(state, unickname) {
      state.unickname = unickname
      sessionStorage.setItem('unickname', unickname)
    },
    updateUid(state, uid) {
      state.uid = uid
      sessionStorage.setItem('uid', uid)
    },
    updateUemail(state, uemail) {
      state.uemail = uemail
      sessionStorage.setItem('uemail', uemail)
    },
    updateUlogo(state, ulogo) {
      state.ulogo = ulogo
      sessionStorage.setItem('ulogo', ulogo)
    },
    logoutUser(state, unickname) {
      state.unickname = ''
      sessionStorage.setItem('unickname', unickname)
      sessionStorage.removeItem('unickname')
    },
  },
  actions: {},
  modules: {},
})
